package com.logic.modular.act.cultivate;

import com.comment.util.message.ResponseResult;
import com.logic.comment.util.JwtUtils;
import com.logic.modular.act.cultivate.vo.CultivateVo;
import com.logic.modular.game.draw.service.PlayerDrawServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@Api(tags = "进入酒馆")
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("/playerTavernAct")
public class PlayerTavernAction {
    @Resource
    private PlayerDrawServiceImpl playerDrawService;

    @ApiOperation(value = "1抽")
    @PostMapping("/drawOne")
    public ResponseResult<?> drawOne(
            @RequestHeader String token,
            @Valid @RequestBody CultivateVo.PlayerTavernVo.upgrade param
    ) {
        Long playerId = JwtUtils.getPlayerId(token);
        return ResponseResult.success(playerDrawService.draw(playerId, param.getType(),1));
    }

    @ApiOperation(value = "10抽")
    @PostMapping("/drawTen")
    public ResponseResult<?> drawTen(
            @RequestHeader String token,
            @Valid @RequestBody CultivateVo.PlayerTavernVo.upgrade param
    ) {
        Long playerId = JwtUtils.getPlayerId(token);
        return ResponseResult.success(playerDrawService.draw(playerId, param.getType(),10));
    }
}